//
//  Body.m
//  Racing
//
//  Created by vy phan on 4/12/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "Body.h"
#import "State.h"

@implementation Body
@synthesize mass;
@synthesize momentOfInertia;

-(id) init
{
	self = [super init];
	if (self != nil) {
		mass = 1;
		momentOfInertia = 1;
#ifdef USE_BODY_OBJ	
		currentState = [[State alloc]initWithOuterBody:self];
		nextState = [[State alloc]initWithOuterBody:self];
#else
		currentState = [[State alloc]init];
		nextState = [[State alloc]init] ;
#endif
	}
	return self;
}

/** Get the "current" state of the body. **/
-(State*) currentState
{
	return currentState;
}

/** Get the potential state of the body at the next time step. **/
-(State*) nextState
{
	return nextState;
}

-(void) integrate:(float)dt  {
	[currentState integrate:dt NextState:nextState];
}

-(void) update;
{
	[currentState copy:nextState];
}

-(void)dealloc
{
	[self->currentState release];
	[self->nextState release];
	[super dealloc];
}
@end
